﻿//-----------------------------------------------------------------------
// <copyright file="IServiceHost.cs" company="FastNET Services">
//     Copyright (c) 2008-2009. All Rights Reserved.
// </copyright>
// <license>
//     GPLv2
// </license>
// <warranty>
//     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
//     BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
//     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
//     DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//     OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// </warranty>
//-----------------------------------------------------------------------
#region Usings

using System;
using GateShift.Services.SDK.Services.Events;
using GateShift.Services.SDK.Services.HostIntegration;
using GateShift.Services.SDK.Services.Interfaces;

#endregion

namespace GateShift.Services.SDK.Services.Hosts
{
    /// <summary>
    /// Direct interface into the manager for services
    /// </summary>
    public interface IServiceHost
    {
        /// <summary>
        /// Event raised when a service finishes initializing
        /// </summary>
        event EventHandler<ServiceInitializedEventArgs> ServiceInitialized;

        /// <summary>
        /// Event raised when a threaded service's state changes
        /// </summary>
        event EventHandler<ServiceStateChangedEventArgs> ServiceStateChanged;

        /// <summary>
        /// Locates a specific service by the service interface
        /// </summary>
        /// <typeparam name="T">IService derived type to lookup</typeparam>
        /// <returns>Instance of IService to utilize</returns>
        T LocateService<T>() where T : IService;

        /// <summary>
        /// Registered an administrative console handler for the service
        /// </summary>
        /// <param name="rootCommand">Base command to trigger command handling through the specified ICommandLineInterfaceHandler</param>
        /// <param name="handler">ICommandLineInterfaceHandler to handle commands with</param>
        void RegisterServiceCommandHandler(string rootCommand, ICommandLineInterfaceHandler handler);
    }
}